package net.towee.client.managers;

import net.towee.model.account.Role;

import com.google.gwt.user.client.rpc.AsyncCallback;

/**
 * Manage roles of users.
 * 
 * <ul>The implementation MUST handler this PUSH events:
 * <li>Role in some group updated - {@link UserRoleUpdatedEvent}</li>
 * </ul>
 * 
 * @author c58
 */
public interface RolesManager {
	/**
	 * Add new role to group with given ID. User must have permission to
	 * manipulate with roles in given group.
	 * 
	 * This method set the id of created role generated on server
	 * and invoke handler with this one.
	 * 
	 * @param groupId
	 * @param role
	 */
	public void addRole(String groupId, Role role, AsyncCallback<Role> handler);

	/**
	 * Update given role in given group
	 * 
	 * @param role
	 */
	public void updateRole(String groupId, Role role, AsyncCallback<Boolean> handler);

	/**
	 * Remove role in given group
	 * 
	 * @param groupId
	 * @param roleId
	 */
	public void removeRole(String groupId, Role role, AsyncCallback<Boolean> handler);

	/**
	 * Set given role as default in given group
	 * 
	 * @param groupId
	 * @param role
	 */
	public void setDefaultRole(String groupId, Role role, AsyncCallback<Void> handler);
	
	/**
	 * Apply role to user in given group
	 * 
	 * @param role
	 * @param userId
	 * @param handler
	 */
	public void applyRoleToUser(Role role, String userId, String groupId, AsyncCallback<Void> handler);
}
